<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>knife download &mdash; chef-client Man Pages</title>
    
    <link rel="stylesheet" href="_static/guide.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    './',
        VERSION:     '',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>


  </head>
  <body>
<div style="background-color: #212c35; text-align: left; padding: 0px 0px 0px 0px">
<a href="http://docs.getchef.com/"><img src="_static/chef_html_logo.png" border="0" alt="Chef"/></a>
</div>


  

    <div class="document">
      <div class="documentwrapper">

          <div class="body">
            
  <div class="section" id="knife-download">
<h1>knife download<a class="headerlink" href="#knife-download" title="Permalink to this headline">¶</a></h1>
<p>The <strong>knife download</strong> subcommand is used to download roles, cookbooks, environments, nodes, and data bags from the Chef server to the current working directory. It can be used to back up data on the Chef server, inspect the state of one or more files, or to extract out-of-process changes users may have made to files on the Chef server, such as if a user made a change that bypassed version source control. This subcommand is often used in conjunction with <tt class="docutils literal"><span class="pre">knife</span> <span class="pre">diff</span></tt>, which can be used to see exactly what changes will be downloaded, and then <tt class="docutils literal"><span class="pre">knife</span> <span class="pre">upload</span></tt>, which does the opposite of <tt class="docutils literal"><span class="pre">knife</span> <span class="pre">download</span></tt>.</p>
<div class="section" id="syntax">
<h2>Syntax<a class="headerlink" href="#syntax" title="Permalink to this headline">¶</a></h2>
<p>This subcommand has the following syntax:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>knife download <span class="o">[</span>PATTERN...<span class="o">]</span> <span class="o">(</span>options<span class="o">)</span>
</pre></div>
</div>
</div>
<div class="section" id="options">
<h2>Options<a class="headerlink" href="#options" title="Permalink to this headline">¶</a></h2>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Review the list of <a class="reference internal" href="knife_common_options.html"><em>common options</em></a> available to this (and all) knife subcommands and plugins.</p>
</div>
<p>This subcommand has the following options:</p>
<dl class="docutils">
<dt><tt class="docutils literal"><span class="pre">--chef-repo-path</span> <span class="pre">PATH</span></tt></dt>
<dd>The path to the chef-repo. This setting will override the default path to the chef-repo. Default: same value as specified by <tt class="docutils literal"><span class="pre">chef_repo_path</span></tt> in client.rb.</dd>
<dt><tt class="docutils literal"><span class="pre">--concurrency</span></tt></dt>
<dd>The number of allowed concurrent connections. Default: <tt class="docutils literal"><span class="pre">10</span></tt>.</dd>
<dt><tt class="docutils literal"><span class="pre">--cookbook-version</span> <span class="pre">VERSION</span></tt></dt>
<dd>The version of a cookbook to download.</dd>
<dt><tt class="docutils literal"><span class="pre">-n</span></tt>, <tt class="docutils literal"><span class="pre">--dry-run</span></tt></dt>
<dd>Use to take no action and only print out results. Default: <tt class="docutils literal"><span class="pre">false</span></tt>.</dd>
<dt><tt class="docutils literal"><span class="pre">--[no-]diff</span></tt></dt>
<dd>Use to download only new and modified files. Set to <tt class="docutils literal"><span class="pre">false</span></tt> to download all files. Default: <tt class="docutils literal"><span class="pre">--diff</span></tt>.</dd>
<dt><tt class="docutils literal"><span class="pre">--[no-]force</span></tt></dt>
<dd>Use <tt class="docutils literal"><span class="pre">--force</span></tt> to download files even when the file on the hard drive is identical to the object on the server (role, cookbook, etc.). By default, files are compared to see if they have equivalent content, and local files are only overwritten if they are different. Default: <tt class="docutils literal"><span class="pre">--no-force</span></tt>.</dd>
<dt><tt class="docutils literal"><span class="pre">--[no-]purge</span></tt></dt>
<dd>Use <tt class="docutils literal"><span class="pre">--purge</span></tt> to delete local files and directories that do not exist on the Chef server. By default, if a role, cookbook, etc. does not exist on the Chef server, the local file for said role will be left alone and NOT deleted. Default: <tt class="docutils literal"><span class="pre">--no-purge</span></tt>.</dd>
<dt><tt class="docutils literal"><span class="pre">--[no-]recurse</span></tt></dt>
<dd>Use <tt class="docutils literal"><span class="pre">--no-recurse</span></tt> to disable downloading a directory recursively. Default: <tt class="docutils literal"><span class="pre">--recurse</span></tt>.</dd>
<dt><tt class="docutils literal"><span class="pre">--repo-mode</span> <span class="pre">MODE</span></tt></dt>
<dd>The layout of the local chef-repo. Possible values: <tt class="docutils literal"><span class="pre">static</span></tt>, <tt class="docutils literal"><span class="pre">everything</span></tt>, or <tt class="docutils literal"><span class="pre">hosted_everything</span></tt>. Use <tt class="docutils literal"><span class="pre">static</span></tt> for just roles, environments, cookbooks, and data bags. By default, <tt class="docutils literal"><span class="pre">everything</span></tt> and <tt class="docutils literal"><span class="pre">hosted_everything</span></tt> are dynamically selected depending on the server type. Default: <tt class="docutils literal"><span class="pre">everything</span></tt> / <tt class="docutils literal"><span class="pre">hosted_everything</span></tt>.</dd>
</dl>
</div>
<div class="section" id="examples">
<h2>Examples<a class="headerlink" href="#examples" title="Permalink to this headline">¶</a></h2>
<p>The following examples show how to use this knife subcommand:</p>
<p><strong>Download the entire chef-repo</strong></p>
<p>To download the entire chef-repo from the Chef server, browse to the top level of the chef-repo and enter:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>knife download /
</pre></div>
</div>
<p><strong>Download the /cookbooks directory</strong></p>
<p>To download the <tt class="docutils literal"><span class="pre">cookbooks/</span></tt> directory from the Chef server, browse to the top level of the chef-repo and enter:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>knife download cookbooks
</pre></div>
</div>
<p>or from anywhere in the chef-repo, enter:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>knife download /cookbooks
</pre></div>
</div>
<p><strong>Download the /environments directory</strong></p>
<p>To download the <tt class="docutils literal"><span class="pre">environments/</span></tt> directory from the Chef server, browse to the top level of the chef-repo and enter:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>knife download environments
</pre></div>
</div>
<p>or from anywhere in the chef-repo, enter:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>knife download /environments
</pre></div>
</div>
<p><strong>Download an environment</strong></p>
<p>To download an environment named &#8220;production&#8221; from the Chef server, browse to the top level of the chef-repo and enter:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>knife download environments/production.json
</pre></div>
</div>
<p>or from the <tt class="docutils literal"><span class="pre">environments/</span></tt> directory, enter:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>knife download production.json
</pre></div>
</div>
<p><strong>Download the /roles directory</strong></p>
<p>To download the <tt class="docutils literal"><span class="pre">roles/</span></tt> directory from the Chef server, browse to the top level of the chef-repo and enter:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>knife download roles
</pre></div>
</div>
<p>or from anywhere in the chef-repo, enter:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>knife download /roles
</pre></div>
</div>
<p><strong>Download cookbooks and roles</strong></p>
<p>To download all cookbooks that start with &#8220;apache&#8221; and belong to the &#8220;webserver&#8221; role, browse to the top level of the chef-repo and enter:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span> knife download cookbooks/apache<span class="se">\*</span> roles/webserver.json
</pre></div>
</div>
</div>
</div>


          </div>

      </div>

  
      <div class="clearer"></div>
    </div>




  </body>
</html>